/**
 * 
 */
package com.sofast.engine.parsepage.create;

import java.util.List;

import com.sofast.bean.SongerBean;
import com.sofast.engine.Spider;

/**
 * @author alex
 *
 */
public class ParseThread implements Runnable {
	
	private static ParseQueue parseQueue;
	
	public String name;
	
	public ParseThread(ParseQueue p) {
		parseQueue = p;
	}

	@Override
	public void run() {
		while(true) {
			SongerBean songer = parseQueue.get();
			if(songer == null) {
				break;
			}
			SongerParse.parseBaidu(songer,name);
		}
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String url = "http://www.1ting.com/group/group0_1.html";// c man
		String url2 = "http://www.1ting.com/group/group0_2.html";// c woman
		String url3 = "http://www.1ting.com/group/group0_3.html";// c team
		String url4 = "http://www.1ting.com/group/group3_14.html";// f man
		String url5 = "http://www.1ting.com/group/group3_15.html";//f woman
		String url6 = "http://www.1ting.com/group/group3_16.html";//f team
		String url7 = "http://www.1ting.com/group/group5_0.html";// k
		String url8 = "http://www.1ting.com/group/group4_0.html";//j
		Spider spider = new Spider(url,"utf-8");
		
		String htmlString = spider.getHtmlString();
		System.out.println(htmlString);
		List<SongerBean> songerList = SongerParse.parseSonger(htmlString,"cm");
		
		ParseQueue parseQueue = new ParseQueue();
		parseQueue.songerList = songerList;
		
		int i = 0;
		while(i<10) {
			ParseThread r = new ParseThread(parseQueue);
			r.name = "r"+i;
			Thread th = new Thread(r);
			
			th.start();
			i++;
		}
	}

}
